//
//  WmcBasePhotoTemplateCell.swift
//  YPWatermarkCamera
//
//  Created by Json on 2023/8/2.
//

import UIKit

class WmcBasePhotoTemplateCell: WmcBaseCollectionCell {
    
    private(set) lazy var containerView: UIView = {
        let view = UIView()
        view.layer.cornerRadius = 4.0
        view.clipsToBounds = true
        return view
    }()
    
    private(set) lazy var photoView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.wmc_grayH18_F0F0F0
        view.layer.cornerRadius = 2.0
        view.clipsToBounds = true
        return view
    }()
    
    var template: WmcPhotoTemplate = .init() {
        didSet {
            titleLabel.text = template.title
            containerView.layer.borderColor = template.isSelected ? UIColor.wmc_mainTheme.cgColor : UIColor.wmc_lineColor.cgColor
            containerView.layer.borderWidth = template.isSelected ? 3.0 : 1.0
        }
    }
    
    let padding = 4.0.wmc_autoHor
    
    override func makeUI() {
        super.makeUI()
        
        // titleLabel
        titleLabel.font = 15.wmc_scaleFont()
        titleLabel.textColor = UIColor.wmc_black85
        titleLabel.textAlignment = .center
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
        }
        // containerView
        contentView.addSubview(containerView)
        containerView.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview()
            make.bottom.equalTo(titleLabel.snp.top).offset(-12.0.wmc_autoHor)
        }
    }
    
}
